package com.sunwayhorizo.health.hl7.rim;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.*;
import org.jboss.seam.annotations.*;
import com.sunwayhorizo.health.common.*;
import com.sunwayhorizo.health.hl7.common.*;
import com.sunwayhorizo.health.hl7.datatypes.*;
import com.sunwayhorizo.health.hl7.persistent.*;

@Name("Rolelink")
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@AttributeOverrides({ @AttributeOverride(name = "typeCode", column = @Column(name = "TYPE_CODE")),
        @AttributeOverride(name = "relation", column = @Column(name = "RELATION_TYPE")),
        @AttributeOverride(name = "describe", column = @Column(name = "DESCRIBE")),
        @AttributeOverride(name = "priorityNumber", column = @Column(name = "PRIORITY_NUM")) })
@DiscriminatorValue("ROLELINK")
public class Rolelink extends RimCoreRoleLink implements Serializable
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @SuppressWarnings("unused")
    @Transient
    private INT sequenceNumber;

    @SuppressWarnings("unused")
    @Transient
    private CS typecode;

    @SuppressWarnings("unused")
    @Transient
    private IVL_TS effectiveTime;

    @SuppressWarnings("unused")
    @Transient
    private CS relation;

    @SuppressWarnings("unused")
    @Transient
    private CS describe;


    public INT getSequenceNumber() throws Hl7Exception
    {
        return DataTypeUtil.getINT(getPriorityNumber());
    }


    public void setSequenceNumber(INT sequenceNumber) throws Hl7Exception
    {
        setPriorityNumber(sequenceNumber.longValue());
    }


    public CS getTypecode() throws Hl7Exception
    {
        if (super.getTypeCode() == null)
        {
            return null;
        }
        else
        {
            return DataTypeUtil.getCS(super.getTypeCode());
        }
    }


    public void setTypeCode(CS typeCode)
    {
        if (typeCode == null)
        {
            return;
        }
        else
        {
            setTypeCode(typeCode.code().stringValue());
        }
    }


    public IVL_TS getEffectiveTime() throws Hl7Exception
    {
        return DataTypeUtil.getIVL_TS(getExistenceStartDateTs(), getExistenceEndDateTs(), getExistenceDateIvlTxt(), getExistenceDateIvlUomCode(), null);
    }


    public void setEffectiveTime(IVL_TS existenceTime)
    {
        if (existenceTime == null)
        {
            return;
        }
        else
        {
            setExistenceStartDateTs(new Timestamp(existenceTime.low().toDate().getTime()));
            setExistenceEndDateTs(new Timestamp(existenceTime.high().toDate().getTime()));
            setExistenceDateTxt(existenceTime.literal().toString());
            PQ pq = (PQ) existenceTime.width();
            setExistenceDateIvlTxt(pq.value().literal().toString());
            setExistenceDateIvlUomCode(pq.unit().code().toString());
        }
    }


    public void setRelation(CS relation)
    {
        if (relation == null)
        {
            return;
        }
        else
        {
            setRelation(relation.code().toString());
        }
    }


    public CS getRelation_Type() throws Hl7Exception
    {
        if (getRelation() == null)
        {
            return null;
        }
        else
        {
            return DataTypeUtil.getCS(getRelation());
        }
    }


    public void setDescribe(CS describe)
    {
        if (describe == null)
        {
            return;
        }
        else
        {
            setDescribe(describe.code().toString());
        }
    }


    public CS getDescribes() throws Hl7Exception
    {
        if (getDescribe() == null)
        {
            return null;
        }
        else
        {
            return DataTypeUtil.getCS(getDescribe());
        }
    }
    
    

}
